//
//  CACategoryView.m
//  LNH
//
//  Created by twentylx on 2018/1/15.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CACategoryView.h"

@implementation CACategoryView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    self.backgroundColor = [UIColor clearColor];
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self addSubview:self.firstButton];
    [self addSubview:self.lineView];
    [self addSubview:self.secondButton];
    [self addSubview:self.line2View];
    [self addSubview:self.thirdButton];
    
    [self setNeedsUpdateConstraints];
}

- (void) updateConstraints {
    [super updateConstraints];
    
    [_firstButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self);
        make.top.equalTo(self);
        make.bottom.equalTo(self);
        make.width.mas_equalTo(SCREEN_WIDTH/3);
    }];
    
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.firstButton.mas_right);
        make.top.equalTo(self).offset(20);
        make.bottom.equalTo(self).offset(-20);
        make.width.mas_equalTo(1);
    }];
    
    [_secondButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.lineView.mas_right);
        make.top.equalTo(self.firstButton);
        make.bottom.equalTo(self.firstButton);
        make.width.mas_equalTo(SCREEN_WIDTH/3);
    }];
    
    [_line2View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.secondButton.mas_right);
        make.top.equalTo(self).offset(20);
        make.bottom.equalTo(self).offset(-20);
        make.width.mas_equalTo(1);
    }];
    
    [_thirdButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.line2View.mas_right);
        make.top.equalTo(self.firstButton);
        make.right.equalTo(self);
        make.bottom.equalTo(self.firstButton);
    }];
}

#pragma mark get & set
- (UIButton *) firstButton {
    if (!_firstButton) {
        _firstButton = [UIButton new];
        [_firstButton setImage:LMImageNamed(@"goods") forState:UIControlStateNormal];
        [_firstButton setTitle:@"优品汇专区" forState:UIControlStateNormal];
        [_firstButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _firstButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [_firstButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    }
    return _firstButton;
}

- (UIView *) lineView {
    if (!_lineView) {
        _lineView = [UIView new];
        [_lineView setBackgroundColor:[UIColor blackColor]];
    }
    return _lineView;
}

- (UIButton *) secondButton {
    if (!_secondButton) {
        _secondButton = [UIButton new];
        [_secondButton setImage:LMImageNamed(@"vip") forState:UIControlStateNormal];
        [_secondButton setTitle:@"vip专区" forState:UIControlStateNormal];
        [_secondButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _secondButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [_secondButton setImageEdgeInsets:UIEdgeInsetsMake(0, -20, 0, 0)];
    }
    return _secondButton;
}

- (UIView *) line2View {
    if (!_line2View) {
        _line2View = [UIView new];
        [_line2View setBackgroundColor:[UIColor blackColor]];
    }
    return _line2View;
}

- (UIButton *) thirdButton {
    if (!_thirdButton) {
        _thirdButton = [UIButton new];
        [_thirdButton setImage:LMImageNamed(@"category") forState:UIControlStateNormal];
        [_thirdButton setTitle:@"分类" forState:UIControlStateNormal];
        [_thirdButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _thirdButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [_thirdButton setImageEdgeInsets:UIEdgeInsetsMake(0, -30, 0, 0)];
    }
    return _thirdButton;
}


@end
